<?php

namespace App\Models;

class Adsenses extends Base
{
    protected $table = 'adsenses';

    protected $fillable = [
        'id','name','title','width','height','description','status','created_at','updated_at'
    ];

    /**
     * 获取列表
     * @param array $params 条件参数
     * @param array $fields 查询的字段
     * @param int $limit 分页数量
     * @return mixed
     */
    protected function getList($params = [], $fields = ['*'], $limit = 10){
        $lists = $this->select($fields)
            ->where(function ($query) use ($params) {
                if(isset($params['kwd']) && $params['kwd']) {
                    $query ->where('name','like','%' . $params['kwd'] . '%')->orWhere('title','like','%' . $params['kwd'] . '%');
                }
            })->where('status','<>',-1)->orderBy('id', 'desc')
            ->paginate($limit);
        return $lists;
    }

}
